//package com.demo.statemachine.d04.redis;
//
//import com.demo.statemachine.d04.OrderEvents;
//import com.demo.statemachine.d04.OrderStates;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.data.redis.connection.RedisConnectionFactory;
//import org.springframework.statemachine.StateMachinePersist;
//import org.springframework.statemachine.data.redis.RedisStateMachineContextRepository;
//import org.springframework.statemachine.data.redis.RedisStateMachinePersister;
//import org.springframework.statemachine.persist.RepositoryStateMachinePersist;
//
///**
// * 状态持久化配置 redis
// */
//@Configuration
//public class PersistConfig {
//    @Autowired
//    private RedisConnectionFactory redisConnectionFactory;
//    /**
//     * 注入RedisStateMachinePersister对象
//     *
//     * @return
//     */
//    @Bean(name = "orderRedisPersister")
//    public RedisStateMachinePersister<OrderStates, OrderEvents> redisPersister() {
//        return new RedisStateMachinePersister<>(redisPersist());
//    }
//
//
//    /**
//     * 通过redisConnectionFactory创建StateMachinePersist
//     *
//     * @return
//     */
//    public StateMachinePersist<OrderStates, OrderEvents,String> redisPersist() {
//        RedisStateMachineContextRepository<OrderStates, OrderEvents> repository =
//                new RedisStateMachineContextRepository<>(redisConnectionFactory);
//        return new RepositoryStateMachinePersist<>(repository);
//    }
//
//
//}
